package com.example.lenovo.myapplication;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;

public class MainActivity extends AppCompatActivity {
    private ImageView imgWanzi;
    private Button btnNext;
    private int[] wanziimgs={R.drawable.timg1,R.drawable.timg2,R.drawable.timg3,R.drawable.timg4,R.drawable.timg5};

    private int index=0;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        imgWanzi=findViewById(R.id.imgWanzi);
        btnNext = findViewById(R.id.btnNext);

        btnNext.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                index=(index+1)%wanziimgs.length;
                imgWanzi.setImageResource(wanziimgs[index]);
            }
        });

    }
}
